package com.milotnt.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.milotnt.mapper.CommunityPostMapper;
import com.milotnt.pojo.CommunityPostEntity;
import com.milotnt.service.CommunityPostService;
import com.milotnt.vo.CommunityPostVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Slf4j
@Transactional
public class CommunityPostServiceImpl extends ServiceImpl<CommunityPostMapper, CommunityPostEntity> implements CommunityPostService {

    @Autowired
    private CommunityPostMapper communityPostMapper;

    @Override
    public List<CommunityPostVo> getAllPosts() {
        return communityPostMapper.getAllPosts();
    }

    @Override
    public Boolean addPost(CommunityPostEntity post) {
        Date date = new Date();
        post.setCreateTime(date);
        return communityPostMapper.insertPost(post);
    }


}
